//JavaScript代码区域
//获取用户信息
var result =JSON.parse(layui.data('user').userkey);

layui.use('element', function(){
    var element = layui.element;
    $(
        function ()
        {
            var user=result.data;

            console.log(user)
            var html_temp=" <img src=\"http://t.cn/RCzsdCq\" class=\"layui-nav-img\">"+user.username;
            //用户名称
            $("#userNameDiv").html(html_temp)

            $.get("/menu",function (data)
            {

                var html="";
                for (var i=0,length=data.length;i<length;i++)
                {

                        html+=" <li class='layui-nav-item layui-nav-itemed'>"

                       var childrens= data[i].childrens;

                    if(childrens)
                    {
                        (function (i)
                        {
                                html+="      <a class=\"\" href=\"javascript:;\">"+data[i].name+"</a>";
                                html+="<dl class=\"layui-nav-child\">";
                                for (var j=0, length=childrens.length;j<length;j++)
                                {
                                   html+="<dd><a href=\""+childrens[j].url+"\" target=\"container_iframe\"> "+childrens[j]["name"]+"</a></dd>";
                                }
                                html+="</dl>"
                        })(i)
                    }else {
                        html+="      <a class=\"\" href=\""+data[i].url+"\" target=\"container_iframe\">"+data[i].name+"</a>";
                    }
                    html+=" </li>"

                }

                $("#menuBox").html(html);
                element.render();

            })

        }
    )

});

var IndexObj=
    {
        createMenu:function (data,doc)
        {
            for (var i=0;i<data.length,i++;)
            {


            }
        }
    }